package com.ctshk.sapp.order.goods.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.order.goods.req.CommodityOrderRefundReq;
import com.ctshk.rpc.order.goods.req.OrderRefundApprovalReq;
import com.ctshk.rpc.order.goods.service.IOrderCommodityRefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 商品退款记录 前端控制器
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-19
 */
@Api(value = "商品退款",tags = "商品退款")
@RestController
@RequestMapping("/order/commodity/refund")
public class OrderCommodityRefundController extends BaseController {

    @DubboReference
    private IOrderCommodityRefundService iOrderCommodityRefundService;

    @ApiOperation(value = "B端-测试-查询退款记录列表", notes = "B端-测试-查询退款记录列表")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "B端-测试-查询退款记录列表", operDesc = "B端-测试-查询退款记录列表")
    @PostMapping("/refundList")
    public Result payment(@RequestBody @Valid CommodityOrderRefundReq req) {
        return iOrderCommodityRefundService.refundList(req);
    }

    @ApiOperation(value = "B端-商品-退款审批", notes = "B端-商品-退款审批")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "B端-商品-退款审批", operDesc = "B端-商品-退款审批")
    @PostMapping("/approval")
    public Result approval(@RequestBody @Valid OrderRefundApprovalReq req){
        return iOrderCommodityRefundService.approval(req);
    }

}
